//
//  landView.m
//  豆瓣2
//
//  Created by dllo on 15/12/19.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "landView.h"

@implementation landView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithFrame:(CGRect)frame
{
 self  = [super initWithFrame:frame];
    if (self) {
        
        [self createSubView];
        
    }
    return self;
}

- (void)createSubView{
    
    self.namelab = [[UILabel alloc]initWithFrame:CGRectMake(160, 100, 200, 50)];
    self.namelab.text = @"用户登陆";
    [self addSubview:self.namelab];
    
    self.alab = [[UILabel alloc]initWithFrame:CGRectMake(70, 200, 200, 30)];
    self.alab.text = @"用户名";
    [self addSubview:self.alab];
    
    
    self.blab = [[UILabel alloc]initWithFrame:CGRectMake(70, 260, 200, 30)];
    self.blab.text = @"密码";
    
    [self addSubview:self.blab];
    
    
    self.afield = [[UITextField alloc]initWithFrame:CGRectMake(150, 200, 200, 30)];
    self.afield.layer.cornerRadius = 15;
    self.afield.placeholder = @"请输入用户名";
    self.afield.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.afield];
    
    
    self.bfield = [[UITextField alloc]initWithFrame:CGRectMake(150, 260, 200, 30)];
    self.bfield.placeholder = @"请输入密码";
    self.bfield.secureTextEntry = YES;
    self.bfield.layer.cornerRadius = 15;
    self.bfield.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.bfield];
    
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(60, 350, 100, 30) ;
    [button setBackgroundImage:[UIImage imageNamed:@"login_button.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button];
    
    // 注册按钮
    UIButton *buttonOne = [UIButton buttonWithType:UIButtonTypeCustom];
    buttonOne.frame = CGRectMake(230,350, 100, 30);
    [buttonOne setBackgroundImage:[UIImage imageNamed:@"register_button.png"] forState:UIControlStateNormal];
    [buttonOne addTarget:self action:@selector(buttonActionOne:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:buttonOne];
    
    
    
}
//登陆按钮
- (void)buttonAction:(UIButton *)bnt{
    
    [self.myDelegate showOne];
    
}
// 注册按钮
- (void)buttonActionOne:(UIButton *)button{
    
    [self.myDelegate show];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    
    [self.afield resignFirstResponder];
    [self.bfield resignFirstResponder];
}

@end
